package com.zhigh.calcite.startproject.adapter;

import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

public enum TableDataType {
    JSON, XML, CSV;

    private final static Map<String, TableDataType> VALUE_MAP;

    public static TableDataType getByName(String name) {
        return VALUE_MAP.getOrDefault(Optional.ofNullable(name).orElse("JSON").toUpperCase(), JSON);
    }

    static {
        VALUE_MAP = Collections.unmodifiableMap(Arrays.stream(values()).collect(Collectors.toMap(TableDataType::name, tableDataType -> tableDataType)));
    }
}
